﻿' A connector consists of two nodes and a connection type. A connection has a
' filtered state. The opacity is reduced when drawing a connection that is 
' filtered. An animation is applied to the brush when the filtered state changes.

Imports System
Imports System.Windows
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Globalization

Public Class DiagramConnectorNode

#Region " fields "

    ' Node location in the diagram.
    Private m_row As DiagramRow
    Private m_group As DiagramGroup
    Private m_node As DiagramNode

#End Region

#Region " properties "

    ''' <summary>
    ''' Node for this connection point.
    ''' </summary>
    Public ReadOnly Property Node() As DiagramNode
        Get
            Return m_node
        End Get
    End Property

    ''' <summary>
    ''' Center of the node relative to the diagram.
    ''' </summary>
    Public ReadOnly Property Center() As Point
        Get
            Return GetPoint(Me.m_node.Center)
        End Get
    End Property


    ''' <summary>
    ''' LeftCenter of the node relative to the diagram.
    ''' </summary>
    Public ReadOnly Property LeftCenter() As Point
        Get
            Return GetPoint(Me.m_node.LeftCenter)
        End Get
    End Property

    ''' <summary>
    ''' RightCenter of the node relative to the diagram.
    ''' </summary>
    Public ReadOnly Property RightCenter() As Point
        Get
            Return GetPoint(Me.m_node.RightCenter)
        End Get
    End Property

    ''' <summary>
    ''' TopCenter of the node relative to the diagram.
    ''' </summary>
    Public ReadOnly Property TopCenter() As Point
        Get
            Return GetPoint(Me.m_node.TopCenter)
        End Get
    End Property



    ''' <summary>
    ''' TopRight of the node relative to the diagram.
    ''' </summary>
    Public ReadOnly Property TopRight() As Point
        Get
            Return GetPoint(Me.m_node.TopRight)
        End Get
    End Property


    ''' <summary>
    ''' TopLeft of the node relative to the diagram.
    ''' </summary>
    Public ReadOnly Property TopLeft() As Point
        Get
            Return GetPoint(Me.m_node.TopLeft)
        End Get
    End Property

    ''' <summary>
    ''' TopCenter of the node relative to the diagram.
    ''' </summary>
    Public ReadOnly Property BottomCenter() As Point
        Get
            Return GetPoint(Me.m_node.BottomCenter)
        End Get
    End Property

#End Region

    Public Sub New(ByVal node As DiagramNode, ByVal group As DiagramGroup, ByVal row As DiagramRow)
        Me.m_node = node
        Me.m_group = group
        Me.m_row = row
    End Sub

    ''' <summary>
    ''' Return the point shifted by the row and group location.
    ''' </summary>
    Private Function GetPoint(ByVal point As Point) As Point
        point.Offset( _
                Me.m_row.Location.X + Me.m_group.Location.X, _
                Me.m_row.Location.Y + Me.m_group.Location.Y)
        Return point
    End Function

End Class
